package au.edu.uq.itee.engg2800.team19;


import java.util.HashMap;
import java.util.Iterator;

public class FrequenciesReceived extends java.util.Observable implements Observer{

	private HashMap<Integer,Integer> hashMap;
	private boolean Plottable;
	private int ordinal;


	public FrequenciesReceived(){
		//Create Hashmap and initialise
		hashMap = new HashMap<Integer,Integer>();
		hashMap.put(1,new Integer(0));
		hashMap.put(2,new Integer(0));
		hashMap.put(3,new Integer(0));
		hashMap.put(4,new Integer(0));
		hashMap.put(5,new Integer(0));
		hashMap.put(6,new Integer(0));
		hashMap.put(7,new Integer(0));
		hashMap.put(8,new Integer(0));
		this.Plottable=false;
		this.ordinal=0;

	}
	public void updateMap(Integer ampl){


		if (this.getPlottable()==true){
			if (this.ordinal==9){
				this.ordinal=1;
			}
			hashMap.put(this.ordinal, ampl);
			setChanged();
			notifyObservers();
			this.ordinal+=1;
		}

	}

	public Integer getval(Integer key){
		return hashMap.get(key);
	}

	public Iterator<Integer> iterator() {
		// TODO Auto-generated method stub
		return hashMap.keySet().iterator();
	}
	@Override
	public void update(String messageText) {
		// TODO Auto-generated method stub

	}
	public void setPlottable(boolean value){
		this.Plottable=value;
	}

	public boolean getPlottable(){
		return Plottable;
	}
	public void resetOrdinal(){
		this.ordinal=0;
	}
	public void setOrdinalback(){
		this.ordinal=this.ordinal-1;
	}
}
